# 基于 ubuntu:22.04 构建的java maven 编译镜像

# FROM harbor.jcdiq.cn/library/gitlab/gitlab-runner:latest as gitlab-runner-java17
FROM ubuntu:22.04 as builder

LABEL maintainer="Libo <libo@jiachengnet.com>"
	
# Default to UTF-8 file.encoding
ENV LANG en_US.UTF-8

RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
    sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
    chmod 777 /tmp && \
	apt-get update && \
    apt-get install -y --no-install-recommends ca-certificates curl

# maven3 下载解压
ENV MAVNE_VERSION=3.9.6 \
    MAVEN_URL=https://dlcdn.apache.org/maven/maven-3 \
	MAVEN_HOME=/opt/maven

RUN set -eux; \	
    MAVEN_PKG="$MAVEN_URL"/"$MAVNE_VERSION"/binaries/apache-maven-"$MAVNE_VERSION"-bin.tar.gz ; \
	MAVEN_SHA256="$(curl "$MAVEN_PKG".sha512)" ; \
	curl --output /tmp/maven.tgz "$MAVEN_PKG" && \
	echo "$MAVEN_SHA256" */tmp/maven.tgz | sha512sum -c; \
	mkdir -p "$MAVEN_HOME"; \
	tar --extract --file /tmp/maven.tgz --directory "$MAVEN_HOME" --strip-components 1

## Get a fresh version of OL8 for the final image	
FROM harbor.jcdiq.cn/library/oracle-jdk:17.0.10-ubuntu-22.04

ENV MAVEN_HOME=/opt/maven
ENV PATH $PATH:$MAVEN_HOME/bin

COPY --from=builder $MAVEN_HOME $MAVEN_HOME
ADD settings.xml ${MAVEN_HOME}/conf/


RUN	mkdir -p /var/repository;
